data = {
    'bound_length': [
        3.1857142857142855, 1.882857142857143, 1.0685714285714287,
        3.5114285714285716, 2.697142857142857, 0.9057142857142858,
        2.2085714285714286, 2.29, 1.2314285714285715, 0.2542857142857143,
        0.5800000000000001, 1.7200000000000002, 3.6742857142857144,
        2.3714285714285714, 1.3942857142857144, 0.6614285714285715,
        2.1271428571428572, 3.9185714285714286, 0.8242857142857143,
        2.7785714285714285, 0.7428571428571429, 0.17285714285714288,
        3.3485714285714288, 1.6385714285714286, 3.837142857142857,
        3.267142857142857, 0.41714285714285715, 2.9414285714285713,
        0.33571428571428574, 0.09142857142857143, 0.01, 1.312857142857143,
        3.755714285714286, 1.1500000000000001, 3.43, 1.9642857142857144,
        2.6157142857142857, 3.592857142857143, 2.045714285714286,
        1.4757142857142858, 1.5571428571428572, 2.5342857142857143,
        2.452857142857143, 0.4985714285714286, 3.0228571428571427,
        1.8014285714285716, 0.9871428571428572, 3.104285714285714, 2.86, 4.0
    ],
    'energy': [
        -0.9333924651145935, -0.9554843902587891, -1.0862277746200562,
        -0.9332254528999329, -0.9345991015434265, -1.1195687055587769,
        -0.9409968852996826, -0.9391208291053772, -1.0498173236846924,
        -0.34263089299201965, -1.108210563659668, -0.9693183898925781,
        -0.9331949949264526, -0.9376772046089172, -1.0165340900421143,
        -1.1319067478179932, -0.9434213042259216, -0.9331746697425842,
        -1.1316341161727905, -0.934231698513031, -1.1372525691986084,
        0.5434669256210327, -0.9332835078239441, -0.9785221219062805,
        -0.9331793189048767, -0.9333295822143555, -0.9468221068382263,
        -0.9337477684020996, -0.7433834671974182, 3.2003893852233887,
        50.30063247680664, -1.0325329303741455, -0.9331858158111572,
        -1.0679296255111694, -0.9332498908042908, -0.9504940509796143,
        -0.9350855350494385, -0.9332077503204346, -0.946533203125,
        -1.0021169185638428, -0.9894348978996277, -0.9357273578643799,
        -0.9365713000297546, -1.0538372993469238, -0.9335928559303284,
        -0.9616959691047668, -1.10384202003479, -0.9334776997566223,
        -0.9339551329612732, -0.9331713914871216
    ]
}

data = [[data['bound_length'][i], data['energy'][i]]
        for i in range(len(data['energy']))]
data.sort()
import numpy as np
data = np.array(data)
data = data[1:, :]
import matplotlib.pyplot as plt
# plt.plot(data[:, 0], data[:, 1])
# plt.show()
import matplotlib.animation as animation

from scipy import interpolate
fun = interpolate.interp1d(data[:, 0], data[:, 1], kind='quadratic')
x = np.linspace(data[0, 0], data[-1, 0], 100)
y = fun(x)
fig = plt.figure()
ax = plt.subplot()
ax.set_xlim([0, 4.5])
ax.set_ylim([-1.25, 3.5])
ax.set_title("Ground energy of H2")
ax.set_xlabel("Inter Atomic Distance (Angstrom)")
ax.set_ylabel("Energy (Hartree)")
line = ax.plot(x[0], y[0], linewidth=2)[0]


def update_lines(num, line, datax, datay):
    line.set_data(datax[:num], datay[:num])


line_ani = animation.FuncAnimation(fig,
                                   update_lines,
                                   100,
                                   fargs=(line, x, y),
                                   interval=1,
                                   repeat=True)
plt.show()